﻿using System;
using Mono.Collections.Generic;

namespace Mono.Cecil
{
	// Token: 0x02000071 RID: 113
	internal sealed class GenericParameterCollection : Collection<GenericParameter>
	{
		// Token: 0x060004A9 RID: 1193 RVA: 0x00003CCF File Offset: 0x00001ECF
		internal GenericParameterCollection(IGenericParameterProvider owner)
		{
			this.owner = owner;
		}

		// Token: 0x060004AA RID: 1194 RVA: 0x00003CE0 File Offset: 0x00001EE0
		internal GenericParameterCollection(IGenericParameterProvider owner, int capacity) : base(capacity)
		{
			this.owner = owner;
		}

		// Token: 0x060004AB RID: 1195 RVA: 0x00003CF2 File Offset: 0x00001EF2
		protected override void OnAdd(GenericParameter item, int index)
		{
			this.UpdateGenericParameter(item, index);
		}

		// Token: 0x060004AC RID: 1196 RVA: 0x0001C8D8 File Offset: 0x0001AAD8
		protected override void OnInsert(GenericParameter item, int index)
		{
			this.UpdateGenericParameter(item, index);
			for (int i = index; i < this.size; i++)
			{
				this.items[i].position = i + 1;
			}
		}

		// Token: 0x060004AD RID: 1197 RVA: 0x00003CF2 File Offset: 0x00001EF2
		protected override void OnSet(GenericParameter item, int index)
		{
			this.UpdateGenericParameter(item, index);
		}

		// Token: 0x060004AE RID: 1198 RVA: 0x00003CFE File Offset: 0x00001EFE
		private void UpdateGenericParameter(GenericParameter item, int index)
		{
			item.owner = this.owner;
			item.position = index;
			item.type = this.owner.GenericParameterType;
		}

		// Token: 0x060004AF RID: 1199 RVA: 0x0001C914 File Offset: 0x0001AB14
		protected override void OnRemove(GenericParameter item, int index)
		{
			item.owner = null;
			item.position = -1;
			item.type = GenericParameterType.Type;
			for (int i = index + 1; i < this.size; i++)
			{
				this.items[i].position = i - 1;
			}
		}

		// Token: 0x0400012C RID: 300
		private readonly IGenericParameterProvider owner;
	}
}
